package org.gap.jseed.injection.annotation;


public enum ThrownException {
	QUIETLY {
		@Override
		public String surroundBodyWithTryCatch(String methodBody) {
			return "try {\n" + methodBody + "\n} catch(Throwable e) {}";
		}
	}, WRAPPED {
		@Override
		public String surroundBodyWithTryCatch(String methodBody) {
			return "try {\n" + methodBody + "\n} catch(Throwable e) {\n    throw new org.gap.jseed.injection.WrappedException(e);\n}";
		}
	}, LOGGED {
		@Override
		public String surroundBodyWithTryCatch(String methodBody) {
			return "try {\n" + methodBody + "\n} catch(Throwable e) {\n" +
				    "    String name = this.getClass().getSimpleName();\n" + 
				    "    java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name);\n" +
				    "    logger.log(java.util.logging.Level.SEVERE, e.getMessage(), e);\n" + 
					"}";
		}
	}, STACK_TRACE {
		@Override
		public String surroundBodyWithTryCatch(String methodBody) {
			return "try {\n" + methodBody + "\n} catch(Throwable e) {\n" +
				    "    e.printStackTrace();\n" + 
					"}";
		}
	};
	
	public abstract String surroundBodyWithTryCatch(String methodBody);
}
